﻿using GeneralServices.PatternCommand;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleAppTestPatternCommand
{
    public class Calculator : IReceiver
    {
        private int _curr = 0;

        #region IReceiver Membres

        public void Action(AbstractCommand command)
        {
            CommandCalcArgs c = (command.Arguments as CommandCalcArgs);
            switch (c.Operateur)
            {
                case '+': _curr += c.Operand; break;
                case '-': _curr -= c.Operand; break;
                case '*': _curr *= c.Operand; break;
                case '/': _curr /= c.Operand; break;
            }
            Console.WriteLine(
              "Current value = {0,3} (following {1} {2})",
              _curr, c.Operateur, c.Operand);
        }

        #endregion
    }
}
